<template>
  <div>
    <!--数据表格-->
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column
          fixed
          prop="type"
          label="待办任务类型"
          min-width="15%">
      </el-table-column>
      <el-table-column
          prop="name"
          label="待办任务名称"
          min-width="40%">
      </el-table-column>
      <el-table-column
          prop="time"
          label="到达时间"
          min-width="25%">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          min-width="20%">
        <template slot-scope="scope">
          <el-button @click="showDialog(scope.row)" type="text" size="small">查看</el-button>
          <el-button @click="roterPush(scope.row)" type="text" size="small">处理</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页工具-->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.currentPage"
        :page-sizes="page.pageSizes"
        :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
    </el-pagination>
    <!--弹出层-->
    <el-dialog
        title="消缺任务详情"
        :visible.sync="showXQ"
        width="40%"
       >
      <el-descriptions title="" direction="vertical" :column="4" border>
        <el-descriptions-item label="任务编号">{{rowDetail.id}}</el-descriptions-item>
        <el-descriptions-item label="任务名称">{{rowDetail.name}}</el-descriptions-item>
        <el-descriptions-item label="下发人" :span="2">{{rowDetail.detail.user.name}}</el-descriptions-item>
        <el-descriptions-item label="下发时间" :span="2">{{rowDetail.time}}</el-descriptions-item>
        <el-descriptions-item label="任务描述" :span="2">{{rowDetail.detail.description}}</el-descriptions-item>
        <el-descriptions-item label="备注信息" :span="2">{{rowDetail.detail.remark}}</el-descriptions-item>
      </el-descriptions>
      <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="showXQ = false">确 定</el-button>
      </span>
    </el-dialog>
    <!--弹出层-->
    <el-dialog
        title="巡检任务详情"
        :visible.sync="showXJ"
        width="40%"
    >
      <el-descriptions title="" direction="vertical" :column="4" border>
        <el-descriptions-item label="任务编号">{{xJDetail.id}}</el-descriptions-item>
        <el-descriptions-item label="任务名称">{{xJDetail.name}}</el-descriptions-item>
        <el-descriptions-item label="巡检线路" :span="2">{{xJDetail.detail.circuitry.name}}</el-descriptions-item>
        <el-descriptions-item label="起始杆号" :span="2">{{xJDetail.detail.startpoleno}}</el-descriptions-item>
        <el-descriptions-item label="终止杆号" :span="2">{{xJDetail.detail.endpoleno}}</el-descriptions-item>
        <el-descriptions-item label="下发人" :span="2">{{xJDetail.detail.user.name}}</el-descriptions-item>
        <el-descriptions-item label="下发时间" :span="2">{{xJDetail.detail.creartime}}</el-descriptions-item>
        <el-descriptions-item label="备注信息" :span="2">{{xJDetail.detail.remarks}}</el-descriptions-item>
      </el-descriptions>
      <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="showXJ = false">确 定</el-button>
      </span>
    </el-dialog>
    <!--弹出层-->
    <el-dialog
        title="缺陷管理详情"
        :visible.sync="showQX"
        width="40%"
    >
      <el-descriptions title="" direction="vertical" :column="4" border>
        <el-descriptions-item label="任务编号">{{qXDetail.name}}</el-descriptions-item>
        <el-descriptions-item label="线路编号">{{qXDetail.detail.cidStr}}</el-descriptions-item>
        <el-descriptions-item label="塔杆编号" :span="2">{{qXDetail.detail.pid}}</el-descriptions-item>
        <el-descriptions-item label="缺陷类型" :span="2">{{qXDetail.detail.bugtype.name}}</el-descriptions-item>
        <el-descriptions-item label="完好率" :span="2">{{qXDetail.detail.intact}}%</el-descriptions-item>
        <el-descriptions-item label="缺陷描述" :span="2">{{qXDetail.detail.description}}</el-descriptions-item>
        <el-descriptions-item label="发现时间" :span="2">{{qXDetail.detail.time}}</el-descriptions-item>
        <el-descriptions-item label="发现人员" :span="2">{{qXDetail.detail.sysUser.name}}</el-descriptions-item>
      </el-descriptions>
      <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="showQX = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "DblbTable",
  data(){
    return{
      xJDetail:{
        detail:{
          user:{

          },
          circuitry:{

          }
        }
      },
      qXDetail:{
        detail:{
          sysUser:{

          },
          user:{


          },
          bugtype:{

          },
          circuitry:{

          }
        }
      },
      rowDetail:{
        detail:{
          user:{

          }
        },
      },
      showXQ:false,
      showXJ:false,
      showQX:false,
      tableData:'',
      page:{
        currentPage:1,
        pageSizes:[5,8],
        pageSize:5,
        total:''
      },
    }
  },
  computed:{
    permList:{
      get(){
        return this.$store.state.menus.permList;
      }
    }
  },
  methods:{
    handleCurrentChange(res){
      this.page.currentPage=res;
      this.getTableData();
    },
    handleSizeChange(res){
      this.page.pageSize=res;
      this.getTableData();
    },
    getDaiBanURL(roles){
      if (roles=="ROLE_root"){
        return"/getDanBan/root/"+this.page.currentPage+"/"+this.page.pageSize;
      }else if (roles=="ROLE_xianluadmin"){
        return"/getDanBan/root/"+this.page.currentPage+"/"+this.page.pageSize;
      }else if (roles=="ROLE_xuanjianyuan"){
        return"/getDaiBan/xuanjianyuan/"+this.page.currentPage+"/"+this.page.pageSize;
      }else if (roles=="ROLE_xiaoqueyuan"){
        return "/getDaiBan/xiaoqueyuan/"+this.page.currentPage+"/"+this.page.pageSize;
      }
    },
    getTableData(){
      let url=this.getDaiBanURL(this.permList[0]);
      this.$axios.post("/nb/user"+url).then(result=>{
        this.tableData=result.data.data.records
        this.page.total=result.data.data.total;
      });
    },
    showDialog(res){
      if (res.type=="消缺任务"){
        this.showXQ=true;
        this.rowDetail=res;
      }else if (res.type=="巡检任务"){
        this.showXJ=true;
        this.xJDetail=res;
      }else if (res.type=="缺陷管理"){
        this.showQX=true;
        this.qXDetail=res;
      }
    },
    roterPush(res){
      if (res.type=="消缺任务"){
        this.$router.push("/debugTask/Xqrwdzyfp");
      }else if (res.type=="巡检任务"){
        this.$router.push("/patrolTask/Xjrwdzyfp");
      }else if (res.type=="缺陷管理"){
        this.$router.push("/bugManager/Qxdjqr");
      }
    }
  },
  created() {
    this.getTableData();
  }
}
</script>

<style scoped>

</style>